<#assign ctx=request.contextPath />
<!DOCTYPE html>
<html>
  <head>
    <title>${Func.getMainCompanyJc()?if_exists}代驾管理平台-完工</title>
    <link rel="shortcut icon" type="image/x-icon" href="${ctx}/assets/img/ezu.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="${ctx}/assets/css/bootstrap.css">
    <link rel="stylesheet" href="${ctx}/assets/css/scojs.css">
    <link rel="stylesheet" href="${ctx}/assets/css/sco.message.css">
    <!--[if lt IE 9]>
        <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
        <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" href="${ctx}/assets/css/form.css">
	<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
	<style>
		.form-group {
			margin-bottom: 2px;
		}
		hr{
			margin-top: 5px;
 			margin-bottom: 15px;
		}
	</style>
  </head>
  <body>
  	<div class="container-fluid">
  		<div class="row" style="margin-top:20px;">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						完工
				    </div>
				    <div class="panel-body">
	    				<form id="submit_form" action="${ctx}/order/complete" class="form-horizontal" method="post">
			               	<input type="hidden" name="id" value="${order.id}" />
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">客户名称：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.clientName?if_exists}<#if member??> (余额：${member.virtual})</#if></p>
			                    </div>
			                    <label class="col-sm-2 control-label">客户电话：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.clientPhone?if_exists}</p>
			                    </div>
			                </div>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">预约地：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.fromPlace?if_exists}</p>
			                    </div>
			                    <label class="col-sm-2 control-label">预约时间：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.serverTime?string("yyyy-MM-dd HH:mm")}</p>
			                    </div>
			                </div>
			                
			                <hr/>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>等候分钟：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="waitedTime" name="waitedTime" type="number" min="0" value="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label"><em>*</em>代驾分钟：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="travelTime" name="travelTime" type="number" min="0" value="0" required/>
			                    </div>
			                </div>
			                
			                <div class="form-group">
			                    
			                </div>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>行驶里程：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="mileage" name="mileage" type="text" min="0" value="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label"><em>*</em>完工时间：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="finishTime" name="finishTime" type="text" value="${.now?string("yyyy-MM-dd HH:mm")}" required/>
			                    </div>
			                </div>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>结算类型：</label>
			                    <div class="col-sm-4">
			                    	<select class="form-control" name="payType" required>
							  			<option value="">--请选择--</option>
							  			<option value="cash">代付</option>
							  			<option value="sign">签单</option>
							  			<option value="balance">余额</option>
							  		</select>
			                    </div>
			                    <label class="col-sm-2 control-label">目的地：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="toPlace" name="toPlace" type="text" min="0" value="${order.toPlace?if_exists}"/>
			                    </div>
			                </div>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>实收金额：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="realCash" name="realCash" type="text" min="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label">报销金额：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="baoxiaoCash" name="baoxiaoCash" type="text" min="0"/>
			                    </div>
			                </div>
			                
			                	
			             	<div class="form-group">
			                    <label class="col-sm-2 control-label">订单备注：</label>
			                    <div class="col-sm-4">
			                    	<textarea class="form-control" cols="20" id="memo" name="memo" rows="2">${order.memo?if_exists}</textarea>
			                    </div>
			                    <label class="col-sm-2 control-label">报销说明：</label>
			                    <div class="col-sm-4">
			                    	<textarea class="form-control" cols="20" id="baoxiaoMemo" name="baoxiaoMemo" rows="2"></textarea>
			                    </div>
			                </div>
			                
			                
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">操作人：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static"><@shiro.principal property='username'/></p>
			                    </div>
			                </div>
			       
			                
			                <div class="form-group">
			                	<div class="col-sm-2">
			                	</div>
			                	<div class="col-sm-10">
			                		<input id="submit_button" type="submit" class="btn btn-primary" value="确认提交">
			                		<input type="button" class="btn btn-default" onclick="window.close();" value="关闭">
			                	</div>
				            </div>
				            
				       
				            
						</form>
	        		</div>
				</div>
			</div>
		</div>
  	</div>
  	<div class="container" style="margin-top:10px;margin-left:0px;">
    	
    	<div class="row">
			
		</div>
   
	</div>
	<script type="text/javascript" language="javascript">window.daijia = {ctx : '${ctx}'};</script>
    <script src="${ctx}/assets/js/jquery-1.11.0.min.js"></script>
    <script src="${ctx}/assets/js/bootstrap.min.js"></script>
    <script src="${ctx}/assets/js/sco.modal.js"></script>
    <script src="${ctx}/assets/js/sco.message.js"></script>
    <script src="${ctx}/assets/js/sco.confirm.js"></script>
    <script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
	<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript">
	
		$(document).ready(function(){
			
			$("#finishTime").datetimepicker({ format: 'yyyy-mm-dd HH:ii', language: 'zh-CN', pickDate: true, pickTime: true, inputMask: false, autoclose: true });
		
			$("#submit_form").submit(function(){
				
				var reg=/^(-?\d+)(.[0-9]{0,2})?$/;
				
				var mileage=$("#mileage").val();
				if(!reg.test(mileage)){
			       $.scojs_message('请输入正确的里程', $.scojs_message.TYPE_ERROR);
			       return false;
			    }
		    
				var realCash=$("#realCash").val();
				if(!reg.test(realCash)){
			       $.scojs_message('请输入正确的实收金额', $.scojs_message.TYPE_ERROR);
			       return false;
			    }
			    
			    var baoxiaoCash=$("#baoxiaoCash").val();
			    if(baoxiaoCash.length>0){
			    	if(!reg.test(baoxiaoCash)){
				       $.scojs_message('请输入正确的报销金额', $.scojs_message.TYPE_ERROR);
				       return false;
				    }
			    }
				
				issubmit=true;
				
				//禁用按钮
				$("#submit_button").attr("disabled",true);
				$("#submit_button").val("提交中...");
				
				$.post($("#submit_form").attr("action"),$("#submit_form").serialize(),function(result){
					if(result.success){
						$.scojs_message("操作成功", $.scojs_message.TYPE_OK);
						setTimeout(function(){
							window.opener.location.reload(true);
			    			window.close();
			    		}, 1000);
					}
					else{
						$.scojs_message(result.message, $.scojs_message.TYPE_ERROR);
						$("#submit_button").attr("disabled",false);
						$("#submit_button").val("确认提交")
						issubmit=false;
					}
				});
				
				return false;
			});
			
		
		});
		
		<!--关闭浏览器 -->  
		var issubmit = false;
		window.onbeforeunload = function () {
			if(!issubmit){
				return ("您确认要离开该页面吗?");
			}
		}  

	</script>
	
  </body>
</html>